import React from 'react'
import WNavBar from '@components/global/navBar'
import ProductModel from '@models/productModel'
import JumpCell from '@components/global/jumpCell'

interface PopInterface {
  title: string
  types: string[]
}

const ProductTypes = (props: PopInterface) => {

  return (
    <WNavBar title={ props.title }>
      <>
        {
          props.types.map((item) => {
            return <JumpCell toPath={ `/product/list?type=${item}` }>{ item }</JumpCell>
          })
        }
      </>
    </WNavBar>
  )
}

ProductTypes.getInitialProps = async () => {
  // 获取所有的 banner 数据
  const data = await ProductModel.loadTypes()

  return {
    title: '作品类型',
    types: data
  }
}

export default ProductTypes
